package com.imy.touch.service;

import com.imy.touch.runnable.ClickedGestureRunnable;
import com.imy.touch.bean.GesturePoint;
import com.imy.touch.interfaces.GestureInterface;
import com.imy.touch.runnable.DownGestureRunnable;
import com.imy.touch.runnable.LongClickedGestureRunnable;
import com.imy.touch.runnable.MoveGestureRunnable;
import com.imy.touch.runnable.SwipeGestureRunnable;
import com.imy.touch.runnable.UpGestureRunnable;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public final class GestureManagerService implements GestureInterface {
  private static final String TAG = "GestureManagerService";
  private static GestureManagerService gCore = new GestureManagerService();

  private ExecutorService executorService;

  public GestureManagerService() {
    executorService = Executors.newSingleThreadExecutor();
  }

  public static GestureManagerService get() {
    return gCore;
  }

  @Override
  public void onDown(GesturePoint point) {
    executorService.execute(new DownGestureRunnable(point));
  }

  @Override
  public void onUp(GesturePoint point) {
    executorService.execute(new UpGestureRunnable(point));
  }

  @Override
  public void onMove(GesturePoint point) {
    executorService.execute(new MoveGestureRunnable(point));
  }

  @Override
  public void onClicked(GesturePoint point) {
    executorService.execute(new ClickedGestureRunnable(point));
  }

  @Override
  public void swipe(GesturePoint start, GesturePoint end, int step, int time) {
    executorService.execute(new SwipeGestureRunnable(start,end,step,time));
  }

  @Override
  public void longClicked(GesturePoint point) {
    executorService.execute(new LongClickedGestureRunnable(point));
  }

}
